package cn.yuanqiao.archive.wenjianzhengli.utils.convert.impl.jave;

import ws.schild.jave.process.ProcessLocator;
import ws.schild.jave.process.ProcessWrapper;
import ws.schild.jave.process.ffmpeg.FFMPEGProcess;

import java.nio.file.Paths;

/*
* 自定义ffmpeg路径
*
* */
public class CustomFFMPEGLocator implements ProcessLocator {
    private static final String defaultExecutablePath = Paths.get(System.getProperty("user.dir"), "ffmpeg", "bin", "ffmpeg").toAbsolutePath().toString();
    private String executablePath;

    public void setExecutablePath(String executablePath) {
        this.executablePath = executablePath;
    }

    @Override
    public String getExecutablePath() {
        if (this.executablePath == null || this.executablePath.equals("") || this.executablePath.length() == 0) {
            return defaultExecutablePath;
        }
        return this.executablePath;
    }

    public ProcessWrapper createExecutor() {
        return new FFMPEGProcess(this.getExecutablePath());
    }

    public static CustomFFMPEGLocator getInstance() {
        return new CustomFFMPEGLocator();
    }
}
